#ifndef ELF_H
#define ELF_H


#define ELF_ST_BIND(i) ((i)>>4)
#define ELF_ST_TYPE(i) ((i)&0xF)
#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf))

typedef struct
{
	unsigned char e_ident[16];
	unsigned short e_type;
	unsigned short e_machine;
	unsigned int e_version;
	unsigned int e_entry;
	unsigned int e_phoff;
	unsigned int e_shoff;
	unsigned int e_flags;
	unsigned short e_ehsize;
	unsigned short e_phentsize;
	unsigned short e_phnum;
	unsigned short e_shentsize;
	unsigned short e_shnum;
	unsigned short e_shstrndx;
}__attribute__((packed)) elf_header;

typedef struct
{
	unsigned int p_type;
	unsigned int p_offset;
	unsigned int p_vaddr;
	unsigned int p_paddr;
	unsigned int p_filesz;
	unsigned int p_memsz;
	unsigned int p_flags;
	unsigned int p_align;
}__attribute__((packed)) elf_phead;

typedef struct
{
	unsigned int name;
	unsigned int type;
	unsigned int flags;
	unsigned int address;
	unsigned int offset;
	unsigned int size;
	unsigned int link;
	unsigned int info;
	unsigned int address_align;
	unsigned int entry_size;
}__attribute__((packed)) elf_section_head;

typedef struct
{
	unsigned int name;
	unsigned int value;
	unsigned int size;
	unsigned char info;
	unsigned char other;
	unsigned short shindex;
}__attribute__((packed)) elf_symbol;

typedef struct
{
	elf_symbol *symtab;
	unsigned int symtab_size;
	char *strtab;
	unsigned int strtab_size;
}__attribute__((packed)) elf_t;

char *elf_lookup(unsigned int address, elf_t *elf);
elf_t elf_from_multiboot(mboot_info *mb);



#endif /* end of include guard: ELF_H */
